﻿// Class to represent a row in the seat reservations grid
function Moneda(id, nombre, compra, venta) {
    var self = this;
    self.id = id;
    self.nombre = nombre;
    self.compra = compra;
    self.venta = venta;

    self.formattedCompra = ko.computed(function () {
        return "$" + self.compra.toFixed(2);
    });
    
    self.formattedVenta = ko.computed(function () {
        return "$" + self.venta.toFixed(2);
    });
}

// Overall viewmodel for this screen, along with initial state
function MonedasViewModel() {
    var self = this;

    // Editable data
    self.monedas = ko.observableArray([
        new Moneda(1, "Dolar Oficial", 5.39, 5.54),
        new Moneda(2, "Dolar Cueva", 7.39, 7.54),
        new Moneda(3, "Dolar Blue", 9.39, 9.54),
        new Moneda(4, "Euro", 10.39, 11.54),
        new Moneda(5, "Libra", 10.39, 11.54),
        new Moneda(6, "Real", 2.39, 2.54),
        new Moneda(7, "Guarani", 521.39, 524.54)
    ]);
}

ko.applyBindings(new MonedasViewModel());